#include <fstream>

using namespace std;

bool CalcSnapperChain(int N, int times)
{
	for (int i=0; i<N; i++)
	{
		if ((times & (1<<i)) == 0)
			return false;
	}

	return true;
}

void RunSnapperChain(const char* fnameIn, const char* fnameOut)
{
	ifstream fin(fnameIn);
	
	int caseCount;
	fin >> caseCount;

	ofstream fout(fnameOut);
	int N, times;

	for (int i=0; i<caseCount; i++)
	{
		fin >> N >> times;
		
		fout<<"Case #"<<i+1<<": ";
		fout<< (CalcSnapperChain(N, times)? "ON":"OFF");
		fout<<"\n";
	}
}
